package com.shop.controller;


import com.shop.annotation.RequireRoles;
import com.shop.entity.MerchantEmployee;
import com.shop.model.PageParam;
import com.shop.model.vo.Rsp;
import com.shop.service.MerchantEmployeeService;
import lombok.AllArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

/**
 * 供应商  供货商列表的信息由采购后自动增加 yyt(MerchantEmployee)表控制层
 *
 * @author yyt
 * @since 2020-11-25 17:42:40
 */
@Validated
@RestController
@AllArgsConstructor
@RequestMapping("employee")
public class MerchantEmployeeController {
    /**
     * 服务对象
     */
    private final MerchantEmployeeService merchantEmployeeService;

    @RequireRoles(roles = {"merchant"})
    @PostMapping("/getEmployeeInfoList")
    public Rsp getEmployeeInfoList(@RequestBody PageParam<MerchantEmployee> pageParam) {
        return merchantEmployeeService.getEmployeeInfoList(pageParam);
    }

    @RequireRoles(roles = {"merchant"})
    @PostMapping("/insertEmp")
    public Rsp insertEmp(@RequestHeader("userId") Integer userId, @RequestBody MerchantEmployee merchantEmployee){
        return merchantEmployeeService.insertEmp(userId,merchantEmployee);
    }

    @RequireRoles(roles = {"merchant"})
    @PostMapping("/updateEmp")
    public Rsp updateEmp(@RequestHeader("userId") Integer userId,@RequestBody MerchantEmployee merchantEmployee){
        return merchantEmployeeService.updateEmp(userId,merchantEmployee);
    }

    @RequireRoles(roles = {"merchant"})
    @PostMapping("/deleteEmp")
    public Rsp deleteEmp(@RequestHeader("userId") Integer userId,@RequestBody MerchantEmployee merchantEmployee){
        return merchantEmployeeService.deleteEmp(userId,merchantEmployee);
    }
}